protected override void OnCleanUp() { if (tracker != null) { tracker.Clear(); tracker = null; } if (workables != null) { for (int i = 0; i < workables.Length; i++) { if ((bool)workables[i]) { Util.KDestroyGameObject(workables[i]); workables[i] = null; } } } base.OnCleanUp(); }
protected override void OnSpawn() { base.OnSpawn(); workables = new SocialGatheringPointWorkable[choreOffsets.Length]; for (int i = 0; i < workables.Length; i++) { int cell = Grid.OffsetCell(Grid.PosToCell(this), choreOffsets[i]); Vector3 pos = Grid.CellToPosCBC(cell, Grid.SceneLayer.Move); GameObject go = ChoreHelpers.CreateLocator("SocialGatheringPointWorkable", pos); SocialGatheringPointWorkable socialGatheringPointWorkable = go.AddOrGet <SocialGatheringPointWorkable>(); socialGatheringPointWorkable.basePriority = basePriority; socialGatheringPointWorkable.specificEffect = socialEffect; socialGatheringPointWorkable.OnWorkableEventCB = OnWorkableEvent; socialGatheringPointWorkable.SetWorkTime(workTime); workables[i] = socialGatheringPointWorkable; } tracker = new SocialChoreTracker(base.gameObject, choreOffsets); tracker.choreCount = choreCount; tracker.CreateChoreCB = CreateChore; base.smi.StartSM(); }