private void SetupNewCharacher() { this.Unit.Unit.View.UpdateAsks(); this.Unit.BirthDay = this.BirthDay; this.Unit.BirthMonth = this.BirthMonth; if (this.Doll != null) { this.Unit.Doll = this.Doll.CreateData(); this.Unit.LeftHandedOverride = new bool?(this.Doll.LeftHanded); } if (this.State.Mode != LevelUpState.CharBuildMode.PreGen) { ItemsCollection.DoWithoutEvents(delegate { LevelUpHelper.AddStartingItems(this.Unit); }); } else { this.Unit.Body.Initialize(); } this.Unit.AddStartingInventory(); foreach (Spellbook spellbook in this.Unit.Spellbooks) { spellbook.UpdateAllSlotsSize(true); int num = spellbook.GetTotalFreeSlotsCount(); for (int i = 0; i < 100; i++) { if (num <= 0) { break; } foreach (BlueprintAbility blueprint in BlueprintRoot.Instance.Progression.CharGenMemorizeSpells) { AbilityData data = new AbilityData(blueprint, spellbook); spellbook.Memorize(data, null); } int totalFreeSlotsCount = spellbook.GetTotalFreeSlotsCount(); if (num <= totalFreeSlotsCount) { break; } num = totalFreeSlotsCount; } } RestController.ApplyRest(this.Unit); if (this.Unit.IsCustomCompanion() && this.State.Mode != LevelUpState.CharBuildMode.Respec) { Game.Instance.EntityCreator.AddEntity(this.Unit.Unit, Game.Instance.Player.CrossSceneState); Game.Instance.Player.RemoteCompanions.Add(this.Unit.Unit); Game.Instance.Player.InvalidateCharacterLists(); this.Unit.Unit.IsInGame = false; this.Unit.Unit.AttachToViewOnLoad(null); if (this.Unit.Unit.View != null) { this.Unit.Unit.View.transform.SetParent(Game.Instance.DynamicRoot, true); } } }
public override void RunAction() { UnitEntityData maybeCaster = this.Context.MaybeCaster; if (maybeCaster == null) { UberDebug.LogError((UnityEngine.Object) this, (object)"Caster is missing", (object[])Array.Empty <object>()); } else { Rounds duration = this.DurationValue.Calculate(this.Context); int count = this.CountValue.Calculate(this.Context); int level = this.LevelValue.Calculate(this.Context); Vector3 clampedPosition = ObstacleAnalyzer.GetNearestNode(this.Target.Point).clampedPosition; UnitEntityView unitEntityView = this.Blueprint.Prefab.Load(false); float radius = (UnityEngine.Object)unitEntityView != (UnityEngine.Object)null ? unitEntityView.Corpulence : 0.5f; FreePlaceSelector.PlaceSpawnPlaces(count, radius, clampedPosition); for (int index = 0; index < count; ++index) { Vector3 relaxedPosition = FreePlaceSelector.GetRelaxedPosition(index, true); UnitEntityData summonedUnit = this.Context.TriggerRule <RuleSummonUnit>(new RuleSummonUnit(maybeCaster, this.Blueprint, relaxedPosition, duration, level) { Context = this.Context, DoNotLinkToCaster = this.DoNotLinkToCaster }).SummonedUnit; var weapon = getWeapon(); if (weapon != null) { ItemsCollection.DoWithoutEvents((Action)(() => summonedUnit.Body.PrimaryHand.InsertItem(weapon.CreateEntity()))); } if (attack_mark_buff != null) { summonedUnit.Ensure <UnitPartSpiritualWeaponTargetMark>().buff = attack_mark_buff; } if ((UnityEngine.Object) this.SummonPool != (UnityEngine.Object)null) { GameHelper.RegisterUnitInSummonPool(this.SummonPool, summonedUnit); } using (this.Context.GetDataScope((TargetWrapper)summonedUnit)) this.AfterSpawn.Run(); summonedUnit.Descriptor.CustomName = custom_name; EventBus.RaiseEvent <IUnitNameHandler>((Action <IUnitNameHandler>)(h => h.OnUnitNameChanged(summonedUnit))); } } }
public override void OnFactDeactivate() { base.OnFactDeactivate(); if (this.m_Applied == null) { return; } if (disable_aoo) { this.Owner.State.RemoveCondition(UnitCondition.DisableAttacksOfOpportunity); } this.m_Applied.HoldingSlot?.Lock.Release(); this.m_Applied.HoldingSlot?.RemoveItem(); ItemsCollection.DoWithoutEvents((Action)(() => this.m_Applied.Collection?.Remove((ItemEntity)this.m_Applied))); this.m_Applied = (ItemEntityWeapon)null; }
public override void OnFactActivate() { base.OnFactActivate(); this.m_Applied = this.weapon.CreateEntity <ItemEntityWeapon>(); this.m_Applied.MakeNotLootable(); if (!this.Owner.Body.PrimaryHand.CanInsertItem((ItemEntity)this.m_Applied)) { this.m_Applied = null; this.Buff.Remove(); } else { if (disable_aoo) { this.Owner.State.AddCondition(UnitCondition.DisableAttacksOfOpportunity, (Buff)null); } ItemsCollection.DoWithoutEvents((Action)(() => this.Owner.Body.PrimaryHand.InsertItem((ItemEntity)this.m_Applied))); this.Owner.Body.PrimaryHand.Lock.Retain(); } }