Ejemplo n.º 1
0
        public override void OnSpawn()
        {
            //Node.cloneNode(parent.Game1.ui.sidebar.ActiveDefaultNode, sword);
            //parent.body.texture = textures.orientedcircle;
            shovelNode.dataStore["shovelnodeparent"] = parent;
            shovelNode.body.pos = parent.body.pos;

            shovelNode.AffectExclusionCheck += (node) => node == parent;

            room.Groups.Items.IncludeEntity(shovelNode);
            Debug.WriteLine(room.Groups.Items.entities.Count);
            shovelNode.OnSpawn();
            shovelNode.body.AddExclusionCheck(parent.body);
            Spring spring = new Spring();

            spring.restdist   = 0;
            spring.springMode = Spring.mode.PullOnly;
            spring.active     = true;
            spring.multiplier = 1000;

            Tether tether = new Tether();

            tether.mindist = 0;
            tether.maxdist = 20;
            tether.active  = true;

            shovelLink = new Link(shovelNode, new HashSet <Node>(), spring);
            shovelLink.AddLinkComponent(tether);

            //to keep the shovel in reach for physics based control
            Tether rangeTether = new Tether();

            rangeTether.mindist = 0;
            rangeTether.maxdist = (int)shovelReach;
            rangeTether.active  = true;
            rangeLink           = new Link(parent, shovelNode, rangeTether);
            if (modeShovelPosition == ModeShovelPosition.PhysicsBased)
            {
                rangeLink.active = true;
            }

            //exclusionDel = delegate(Collider c1, Collider c2)
            //{
            //    return shovelLink.active && shovelLink.targets.Contains(c2.parent);
            //};
            //shovelNode.body.ExclusionCheck += exclusionDel;
            //parent.body.ExclusionCheck += exclusionDel;
        }
        private bool AddLinkComponent(object[] o, Link link)
        {
            //bool writeable = false;
            Type t = (Type)o[1];

            object linkComp = Activator.CreateInstance(t);

            link.AddLinkComponent((ILinkable)linkComp);
            //ILinkable l = (ILinkable)linkComp;
            //link.components.Add(l);

            ActiveInspectorParent.DoubleClickItem(this);
            return true;
            /*
            if (!inspectorArea.editNode.comps.ContainsKey((comp)o[1]))
            {
                inspectorArea.editNode.addComponent((comp)o[1], true);
                inspectorArea.ActiveInspectorParent.DoubleClickItem(inspectorArea);
            }
            else PopUp.Prompt(ui,
                        "The node already contains this component. Overwrite to default component?",
                        action: delegate(bool k, object ans) { writeable = k; return true; });

            if (writeable)
            {
                inspectorArea.editNode.addComponent((comp)o[1], true);
                inspectorArea.ActiveInspectorParent.DoubleClickItem(inspectorArea);
                return true;
            }
            else
            {
                return false;
            }
            */
        }
Ejemplo n.º 3
0
        public override void OnSpawn()
        {
            //Node.cloneNode(parent.Game1.ui.sidebar.ActiveDefaultNode, sword);
            //parent.body.texture = textures.orientedcircle;
            shovelNode.dataStore["shovelnodeparent"] = parent;
            shovelNode.body.pos = parent.body.pos;

            shovelNode.AffectExclusionCheck += (node) => node == parent;

            room.groups.items.IncludeEntity(shovelNode);
            shovelNode.OnSpawn();
            shovelNode.body.AddExclusionCheck(parent.body);
            Spring spring = new Spring();
            spring.restdist = 0;
            spring.springMode = Spring.mode.PullOnly;
            spring.active = true;
            spring.multiplier = 1000;

            Tether tether = new Tether();
            tether.mindist = 0;
            tether.maxdist = 20;
            tether.active = true;

            shovelLink = new Link(shovelNode, new HashSet<Node>(), spring);
            shovelLink.AddLinkComponent(tether);

            //to keep the shovel in reach for physics based control
            Tether rangeTether = new Tether();
            rangeTether.mindist = 0;
            rangeTether.maxdist = (int)shovelReach;
            rangeTether.active = true;
            rangeLink = new Link(parent, shovelNode, rangeTether);
            if (modeShovelPosition == ModeShovelPosition.PhysicsBased)
            {
                rangeLink.active = true;
            }

            //exclusionDel = delegate(Collider c1, Collider c2)
            //{
            //    return shovelLink.active && shovelLink.targets.Contains(c2.parent);
            //};
            //shovelNode.body.ExclusionCheck += exclusionDel;
            //parent.body.ExclusionCheck += exclusionDel;
        }
Ejemplo n.º 4
0
        public override void OnSpawn()
        {
            shootNode.dataStore["linknodeparent"] = parent;
            shootNode.body.pos = parent.body.pos;
            shootNode.addComponent <ColorChanger>(true);
            shootNode.AffectExclusionCheck += (node) => node == parent;
            room.Groups.Items.IncludeEntity(shootNode);
            shootNode.OnSpawn();
            shootNode.body.AddExclusionCheck(parent.body);
            shootNode.active = false;
            shootNode.movement.maxVelocity.value = 50f;

            spring            = new Spring();
            spring.restdist   = 0;
            spring.springMode = Spring.mode.PushOnly;
            spring.multiplier = 400;

            //Tether tether = new Tether();
            //tether.mindist = 0;
            //tether.maxdist = 20;
            //tether.active = true;

            //shootNodeLink = new Link(parent, shootNode, spring);
            //shootNodeLink.IsEntangled = true;
            ////shovelLink.components.Add(tether);

            grav      = new Gravity();
            grav.mode = Gravity.Mode.ConstantForce;
            //grav.Repulsive = true;
            grav.multiplier = 100;

            shootLink = new Link(parent, shootNode, grav);
            shootLink.AddLinkComponent(spring, true);


            //
            Gravity attachGrav = new Gravity();

            attachGrav.multiplier = 100;
            attachGrav.mode       = Gravity.Mode.ConstantForce;

            Tether aTether = new Tether();

            aTether.maxdist   = 100;
            aTether.mindist   = 0;
            aTether.activated = true;

            Spring aSpring = new Spring();

            aSpring.springMode = Spring.mode.PushAndPull;
            aSpring.multiplier = 100;
            aSpring.restdist   = 0;

            attachedNodesQueue = new Queue <Node>();
            //attachLink = new Link(parent, new HashSet<Node>(), attachGrav); //targetsToSelf

            attachLink = new Link(new HashSet <Node>(), new HashSet <Node>(), aTether); //targetsChained
            attachLink.FormationType = formationtype.Chain;
            //attachLink.AddLinkComponent(aTether, true);
            //attachLink.AddLinkComponent(attachGrav, true);


            shootNode.body.OnCollisionEnter += (n, other) => {
                if (other == parent)
                {
                    return;
                }
                if (linkMode == LinkMode.TargetsToSelf)
                {
                    if (!attachLink.targets.Contains(other))
                    {
                        attachLink.targets.Add(other);
                        attachedNodesQueue.Enqueue(other);
                        attachLink.active = true;
                    }
                }
                else if (linkMode == LinkMode.TargetsToTargets)
                {
                    if (!attachLink.sources.Contains(other))
                    {
                        attachLink.sources.Add(other);
                        attachLink.targets.Add(other);
                        attachedNodesQueue.Enqueue(other);
                        attachLink.active = true;
                    }
                }
                else if (linkMode == LinkMode.TargetsChained)
                {
                    if (!attachLink.sources.Contains(other))
                    {
                        attachedNodesQueue.Enqueue(other);
                        attachLink.formation.AddChainNode(other);
                        attachLink.active = true;
                    }
                }
            };

            parent.body.ExclusionCheck += (c1, c2) =>
                                          attachLink.targets.Contains(c2.parent);
        }
Ejemplo n.º 5
0
        public override void OnSpawn()
        {
            shootNode.dataStore["linknodeparent"] = parent;
            shootNode.body.pos = parent.body.pos;
            shootNode.addComponent<ColorChanger>(true);
            shootNode.AffectExclusionCheck += (node) => node == parent;
            room.groups.items.IncludeEntity(shootNode);
            shootNode.OnSpawn();
            shootNode.body.AddExclusionCheck(parent.body);
            shootNode.active = false;
            shootNode.movement.maxVelocity.value = 50f;

            spring = new Spring();
            spring.restdist = 0;
            spring.springMode = Spring.mode.PushOnly;
            spring.multiplier = 400;

            //Tether tether = new Tether();
            //tether.mindist = 0;
            //tether.maxdist = 20;
            //tether.active = true;

            //shootNodeLink = new Link(parent, shootNode, spring);
            //shootNodeLink.IsEntangled = true;
            ////shovelLink.components.Add(tether);

            grav = new Gravity();
            grav.mode = Gravity.Mode.ConstantForce;
            //grav.Repulsive = true;
            grav.multiplier = 100;

            shootLink = new Link(parent, shootNode, grav);
            shootLink.AddLinkComponent(spring, true);

            //
            Gravity attachGrav = new Gravity();
            attachGrav.multiplier = 100;
            attachGrav.mode = Gravity.Mode.ConstantForce;

            Tether aTether = new Tether();
            aTether.maxdist = 100;
            aTether.mindist = 0;
            aTether.activated = true;

            Spring aSpring = new Spring();
            aSpring.springMode = Spring.mode.PushAndPull;
            aSpring.multiplier = 100;
            aSpring.restdist = 0;

            attachedNodesQueue = new Queue<Node>();
            //attachLink = new Link(parent, new HashSet<Node>(), attachGrav); //targetsToSelf

            attachLink = new Link(new HashSet<Node>(), new HashSet<Node>(), aTether); //targetsChained
            attachLink.FormationType = formationtype.Chain;
            //attachLink.AddLinkComponent(aTether, true);
            //attachLink.AddLinkComponent(attachGrav, true);

            shootNode.body.OnCollisionEnter += (n, other) =>
                {
                    if (other == parent) return;
                    if (linkMode == LinkMode.TargetsToSelf)
                    {
                        if (!attachLink.targets.Contains(other))
                        {
                            attachLink.targets.Add(other);
                            attachedNodesQueue.Enqueue(other);
                            attachLink.active = true;
                        }
                    }
                    else if (linkMode == LinkMode.TargetsToTargets)
                    {
                        if (!attachLink.sources.Contains(other))
                        {
                            attachLink.sources.Add(other);
                            attachLink.targets.Add(other);
                            attachedNodesQueue.Enqueue(other);
                            attachLink.active = true;
                        }
                    }
                    else if (linkMode == LinkMode.TargetsChained)
                    {
                        if (!attachLink.sources.Contains(other))
                        {
                            attachedNodesQueue.Enqueue(other);
                            attachLink.formation.AddChainNode(other);
                            attachLink.active = true;
                        }
                    }
                };

            parent.body.ExclusionCheck += (c1, c2) =>
                attachLink.targets.Contains(c2.parent);
        }