-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFactionSelector.cs
136 lines (126 loc) · 6.64 KB
/
FactionSelector.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using EffectSourceConditions;
using InstanceIDs;
using SideLoader;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TinyHelper;
using UnityEngine;
namespace Crusader
{
using EffectSourceConditions;
public class SourceConditionCrusaderFaction : SourceCondition
{
public FactionSelector.CrusaderFaction Faction = FactionSelector.CrusaderFaction.None;
public bool Invert = false;
public override bool CharacterHasRequirement(Character character)
{
return (Crusader.Instance.FactionSelectorInstance.PlayerFactions[character.UID] == Faction) ^ Invert;
}
}
public class ConditionCrusaderFaction : EffectCondition
{
public FactionSelector.CrusaderFaction Faction = FactionSelector.CrusaderFaction.None;
protected override bool CheckIsValid(Character _affectedCharacter)
{
return (Crusader.Instance.FactionSelectorInstance.PlayerFactions[_affectedCharacter.UID] == Faction) ^ Invert;
}
}
public class FactionSelector
{
public enum CrusaderFaction {
HolyMission,
BlueChamber,
HeroicKingdom,
None,
}
public Dictionary<string, CrusaderFaction> PlayerFactions = new Dictionary<string, CrusaderFaction>();
public FactionSelector()
{
SL.OnSceneLoaded += OnSceneLoadedReportFaction;
}
private void OnSceneLoadedReportFaction()
{
var character = CharacterManager.Instance.GetFirstLocalCharacter();
if (character.IsWorldHost)
{
var faction = CrusaderFaction.None;
if (QuestRequirements.HasQuestKnowledge(character, new [] { IDs.questionsAndCorruptionID }, LogicType.Any))
{
faction = CrusaderFaction.HolyMission;
}
if (QuestRequirements.HasQuestKnowledge(character, new [] { IDs.heroicPeacemakerID }, LogicType.Any))
{
faction = CrusaderFaction.HeroicKingdom;
}
if (QuestRequirements.HasQuestKnowledge(character, new [] { IDs.mixedLegaciesID }, LogicType.Any))
{
faction = CrusaderFaction.BlueChamber;
}
PlayerFactions[character.UID] = faction;
}
CrusaderRPCManager.Instance.photonView.RPC("AssignFaction", PhotonTargets.All, new object[] { character.UID.ToString(), PlayerFactions.ContainsKey(character.UID) ? PlayerFactions[character.UID] : CrusaderFaction.None });
}
public static ParticleSystem.MinMaxGradient holyMissionMinMaxGradient = new ParticleSystem.MinMaxGradient(new Color(1, 0.83f, 0.7f, 0.5f) / 2, new Color(1, 0.5f, 0.2f, 0.5f) / 2);
public static ParticleSystem.MinMaxGradient blueChamberCollectiveMinMaxGradient = new ParticleSystem.MinMaxGradient(new Color(0.73f, 1f, 0.83f, 0.5f) / 2, new Color(0.3f, 1f, 0.5f, 0.5f) / 2);
public static void SetWeaponTrailForFaction(Skill skill)
{
foreach(var tup in new Tuple<CrusaderFaction, ParticleSystem.MinMaxGradient>[]
{
new Tuple<CrusaderFaction, ParticleSystem.MinMaxGradient>(CrusaderFaction.HolyMission, holyMissionMinMaxGradient),
new Tuple<CrusaderFaction, ParticleSystem.MinMaxGradient>(CrusaderFaction.HeroicKingdom, holyMissionMinMaxGradient),
new Tuple<CrusaderFaction, ParticleSystem.MinMaxGradient>(CrusaderFaction.BlueChamber, blueChamberCollectiveMinMaxGradient),
})
{
var particleTransform = TinyGameObjectManager.MakeFreshTransform(skill.transform, EffectSourceConditions.EFFECTS_CONTAINER_ACTIVATION, true, true);
new SL_PlayVFX()
{
VFXPrefab = SL_PlayVFX.VFXPrefabs.VFXMomentOfTruth,
}.ApplyToTransform(particleTransform);
foreach (var vfxSystem in particleTransform.gameObject.GetComponents<PlayVFX>())
{
foreach (ParticleSystem particles in vfxSystem.VFX.gameObject.GetComponentsInChildren<ParticleSystem>())
{
var m = particles.main;
m.startColor = tup.Item2;
}
}
var requirementTransform = TinyGameObjectManager.GetOrMake(particleTransform, EffectSourceConditions.SOURCE_CONDITION_CONTAINER, true, true);
requirementTransform.gameObject.AddComponent<SourceConditionCrusaderFaction>().Faction = tup.Item1;
}
}
public static void SetCasterParticleForFaction(Skill skill, float delay)
{
foreach (var tup in new Tuple<CrusaderFaction, ParticleSystem.MinMaxGradient>[]
{
new Tuple<CrusaderFaction, ParticleSystem.MinMaxGradient>(CrusaderFaction.HeroicKingdom, holyMissionMinMaxGradient),
new Tuple<CrusaderFaction, ParticleSystem.MinMaxGradient>(CrusaderFaction.HolyMission, holyMissionMinMaxGradient),
new Tuple<CrusaderFaction, ParticleSystem.MinMaxGradient>(CrusaderFaction.BlueChamber, blueChamberCollectiveMinMaxGradient),
})
{
var particleTransform = TinyGameObjectManager.MakeFreshTransform(skill.transform, EffectSourceConditions.EFFECTS_CONTAINER_ACTIVATION, true, true);
new SL_PlayVFX()
{
VFXPrefab = SL_PlayVFX.VFXPrefabs.VFXBoonEthereal,
Delay = delay
}.ApplyToTransform(particleTransform);
foreach (var vfxSystem in particleTransform.gameObject.GetComponents<PlayVFX>())
{
foreach (ParticleSystem particles in vfxSystem.VFX.gameObject.GetComponentsInChildren<ParticleSystem>(true))
{
var m = particles.main;
m.startColor = tup.Item2;
var s = particles.colorBySpeed;
s.color = tup.Item2;
var l = particles.colorOverLifetime;
s.color = tup.Item2;
}
}
var requirementTransform = TinyGameObjectManager.GetOrMake(particleTransform, EffectSourceConditions.SOURCE_CONDITION_CONTAINER, true, true);
requirementTransform.gameObject.AddComponent<SourceConditionCrusaderFaction>().Faction = tup.Item1;
}
}
}
}