public override void PostLoad() { base.PostLoad(); for (int i = 0; i < Joints.Length; i++) { Joints[i] = (Joint)Components.ComponentsManager.GetComponent(j[i]); Joints[i].ContainingComponents.Add(this); } for (int i = 0; i < Wires.Length; i++) { Wires[i] = (Wire)Components.ComponentsManager.GetComponent(w[i]); } for (int i = 0; i < lasers.Length; i++) { lasers[i] = new MovementDetectorLaser(); lasers[i].Graphics.Position = Graphics.Center; lasers[i].type = (MovementDetectorLaser.Direction)i; } }
public override void InitAddChildComponents() { for (int i = 0; i < Joints.Length; i++) { switch (rotation) { case Rotation.cw0: Joints[i] = Joint.GetJoint(new Vector2(JointLocs0cw[i * 2], JointLocs0cw[i * 2 + 1]) + Graphics.Position); break; case Rotation.cw90: break; case Rotation.cw180: break; case Rotation.cw270: break; default: break; } Joints[i].CanRemove = false; Joints[i].CanRemove = false; Joints[i].ContainingComponents.Add(this); } for (int i = 4; i < Joints.Length; i++) { Joints[i].CanProvidePower = true; Joints[i].CanBeGround = true; Joints[i].IsGround = true; Joints[i].Graphics.Visible = false; } for (int i = 0; i < Joints.Length; i++) { Joints[i].Initialize(); } for (int i = 0; i < Wires.Length; i++) { Wires[i] = new Wire(Joints[i], Joints[i + 4]); Wires[i].Resistance = 400; Wires[i].AddComponentToManager(); Wires[i].Graphics.Visible = false; Wires[i].IsRemovable = false; Wires[i].Initialize(); } for (int i = 0; i < lasers.Length; i++) { lasers[i] = new MovementDetectorLaser(); lasers[i].Graphics.Position = Graphics.Center; lasers[i].type = (MovementDetectorLaser.Direction)i; //lasers[i].AddComponentToManager(); //lasers[i].Initialize(); } GlobalEvents.onComponentPlacedByPlayer += new GlobalEvents.ComponentEventHandler(GlobalEvents_onComponentPlacedByPlayer); GlobalEvents.onComponentRemoved += new GlobalEvents.ComponentEventHandler(GlobalEvents_onComponentRemovedByPlayer); GlobalEvents.onComponentMoved += new GlobalEvents.ComponentEventHandler(GlobalEvents_onComponentMoved); }