public override bool OnHitAsProjectile(CellFace?cellFace, ComponentBody componentBody, WorldItem worldItem)
        {
            Projectile projectile = worldItem as Projectile;

            (((projectile != null) ? projectile.Owner : null) as ComponentPlayer).ComponentBody.Position = worldItem.Position;
            return(true);
        }
        public override void OnCollide(CellFace cellFace, float velocity, ComponentBody componentBody)
        {
            int id = ILibrary.getItemId(SubsystemTerrain.Terrain.GetCellValueFast(cellFace.Point.X, cellFace.Point.Y, cellFace.Point.Z));

            switch (id)
            {
            case 64:
                if (cellFace.Face == 4)
                {
                    if (tranmitPoints.TryGetValue(cellFace.Point, out NewMutiBlockCheck.TranmitResult result))
                    {
                        if (component == null)
                        {
                            component = componentBody.Entity.FindComponent <ComponentPlayer>();
                        }
                        if (component != null && !tranFLag && leftFLag)
                        {
                            tranFLag       = true;
                            leftFLag       = false;
                            mcomponentBody = componentBody;
                            if (result.directionIsX)
                            {
                                tranca.Add(new Vector3(result.connectPoint.X, result.connectPoint.Y + 1, result.connectPoint.Z + 1));
                            }
                            else
                            {
                                tranca.Add(new Vector3(result.connectPoint.X + 1, result.connectPoint.Y + 1, result.connectPoint.Z));
                            }
                        }
                    }
                }
                break;
            }
        }
示例#3
0
        public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            m_subsystemGameInfo           = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
            m_subsystemParticles          = base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true);
            m_subsystemAudio              = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true);
            m_subsystemTime               = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
            m_subsystemTerrain            = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
            m_subsystemPickables          = base.Project.FindSubsystem <SubsystemPickables>(throwOnError: true);
            m_componentGui                = base.Entity.FindComponent <ComponentGui>(throwOnError: true);
            m_componentHumanModel         = base.Entity.FindComponent <ComponentHumanModel>(throwOnError: true);
            m_componentBody               = base.Entity.FindComponent <ComponentBody>(throwOnError: true);
            m_componentOuterClothingModel = base.Entity.FindComponent <ComponentOuterClothingModel>(throwOnError: true);
            m_componentVitalStats         = base.Entity.FindComponent <ComponentVitalStats>(throwOnError: true);
            m_componentLocomotion         = base.Entity.FindComponent <ComponentLocomotion>(throwOnError: true);
            m_componentPlayer             = base.Entity.FindComponent <ComponentPlayer>(throwOnError: true);
            SteedMovementSpeedFactor      = 1f;
            Insulation                    = 0f;
            LeastInsulatedSlot            = ClothingSlot.Feet;
            m_clothes[ClothingSlot.Head]  = new List <int>();
            m_clothes[ClothingSlot.Torso] = new List <int>();
            m_clothes[ClothingSlot.Legs]  = new List <int>();
            m_clothes[ClothingSlot.Feet]  = new List <int>();
            ValuesDictionary value = valuesDictionary.GetValue <ValuesDictionary>("Clothes");

            SetClothes(ClothingSlot.Head, HumanReadableConverter.ValuesListFromString <int>(';', value.GetValue <string>("Head")));
            SetClothes(ClothingSlot.Torso, HumanReadableConverter.ValuesListFromString <int>(';', value.GetValue <string>("Torso")));
            SetClothes(ClothingSlot.Legs, HumanReadableConverter.ValuesListFromString <int>(';', value.GetValue <string>("Legs")));
            SetClothes(ClothingSlot.Feet, HumanReadableConverter.ValuesListFromString <int>(';', value.GetValue <string>("Feet")));
            Display.DeviceReset += Display_DeviceReset;
        }
        public async Task <int> CreateComponent(ComponentBody componentBody, int locationId)
        {
            // save image to blob
            string url = await azureService.saveImageToBlobStorage(componentBody.Image);

            // create the component exercises
            List <ComponentExercise> componentExercises = new List <ComponentExercise>();

            foreach (int exerciseId in componentBody.Exercises)
            {
                componentExercises.Add(new ComponentExercise
                {
                    ExerciseId = exerciseId
                });
            }

            // create new component
            Component newComponent = new Component
            {
                Name               = componentBody.Name,
                Description        = componentBody.Description,
                Image              = url,
                LocationId         = locationId,
                ComponentExercises = componentExercises
            };

            // save component to database
            newComponent = await componentRepository.CreateAsync(newComponent);

            return(newComponent.Id);
        }
        public async Task <Component> UpdateComponent(ComponentBody componentBody, int locationId, int componentId)
        {
            // get the current component
            Component oldComponent = await componentRepository.ReadAsync(componentId);

            // if component is not in location
            if (oldComponent == null || oldComponent.LocationId != locationId)
            {
                return(null);
            }

            // create updated component
            Component updateComponent = new Component
            {
                Id          = componentId,
                Name        = componentBody.Name,
                Description = componentBody.Description,
            };

            if (componentBody.Exercises != null)
            {
                // create the component exercises
                List <ComponentExercise> componentExercises = new List <ComponentExercise>();
                foreach (int exerciseId in componentBody.Exercises)
                {
                    componentExercises.Add(new ComponentExercise
                    {
                        ExerciseId = exerciseId
                    });
                }
                updateComponent.ComponentExercises = componentExercises;
            }

            if (componentBody.Image != null)
            {
                // save image to blob
                string url = await azureService.saveImageToBlobStorage(componentBody.Image);

                updateComponent.Image = url;

                // delete old image
                azureService.deleteImageFromBlobStorage(oldComponent.Image);
            }

            // save component to database
            Component updatedComponent = await componentRepository.UpdateAsync(updateComponent);

            return(updatedComponent);
        }
示例#6
0
            public override bool ProcessLine(string line)
            {
                base.ProcessLine();
                ComponentBody ComponentBody = new ComponentBody(line);

                if (ComponentNumber >= ModulesL.Count)
                {
                    missed++;
                    return(false);
                }
                if (ComponentBody != null)
                {
                    ModulesL[ComponentNumber].ComponentBodies.Add(ComponentBody);
                }
                return(true);
            }
    public Reflector(Vector2Int position, int rotation, bool flipped) : base(position, new Vector2Int(1, 1), rotation, flipped)
    {
        Vector2 mirrorOffset  = new Vector2(.3f, .1f);
        Vector2 bodyOffset    = new Vector2(.1f, .3f);
        Vector2 componentSize = new Vector2(.6f, .6f);

        //the format of the layout
        int format = rotation;

        //if flipped move to the format index
        if (flipped)
        {
            format = (rotation + 1) % 4;
        }

        //update the offsets
        if (format == 0)
        {
            //does nothing
        }
        else if (format == 1)
        {
            mirrorOffset = new Vector2(.1f, .1f);
            bodyOffset   = new Vector2(.3f, .3f);
        }
        else if (format == 2)
        {
            mirrorOffset = new Vector2(.1f, .3f);
            bodyOffset   = new Vector2(.3f, .1f);
        }
        else if (format == 3)
        {
            mirrorOffset = new Vector2(.3f, .3f);
            bodyOffset   = new Vector2(.1f, .1f);
        }

        Mirror        mir  = new Mirror(new Rect(position + mirrorOffset, componentSize), rotation, flipped);
        ComponentBody body = new ComponentBody(new Rect(position + bodyOffset, componentSize));

        this.componentPieces.Add(body);
        this.componentPieces.Add(mir);
    }
示例#8
0
            // output the module as a Library component
            public string ToModule()
            {
                StringBuilder ret = new StringBuilder("");

                ret.Append($"  (module \"{Name}\" (layer {Layer}) {Tedit} {Tstamp}\n");
                ret.Append($"  (descr \"\")");
                ret.Append($"  (tags \"\")");
                if (Attr != "")
                {
                    ret.Append($"  (attr {Attr})\n");
                }

                foreach (var String in Strings)
                {
                    string str;

                    str = String.ToString(X, Y, Rotation);

                    if (str.Contains("fp_text reference"))
                    {
                        str = String.ToRefString(X, Y, Rotation);
                    }

                    ret.Append(str);
                }
                foreach (var Pad in Pads)
                {
                    ret.Append(Pad.ToModuleString(X, Y, Rotation));
                }
                foreach (var Line in Lines)
                {
                    ret.Append(Line.ToString(X, Y, Rotation));
                }
                // Vias in components are done as pads
                //                foreach (var Via in Vias)
                //                {
                //                    ret += Via.ToString(X, Y);
                //                }
                foreach (var Arc in Arcs)
                {
                    ret.Append(Arc.ToString(X, Y, Rotation));
                }
                foreach (var Polygon in Polygons)
                {
                    ret.Append(Polygon.ToString());
                }
                foreach (var Fill in Fills)
                {
                    ret.Append(Fill.ToString(X, Y, -Rotation));
                }
                foreach (var region in Regions)
                {
                    ret.Append(region.ToString(X, Y, -Rotation));
                }
                foreach (var ComponentBody in ComponentBodies)
                {
                    ret.Append(ComponentBody.ToString(X, Y, -Rotation));
                }
                ret.Append("  )\n");
                return(ret.ToString());
            }
    public InteractiveComponent(Vector2Int position, Vector2Int size, int rotation, bool flipped, int numSenders, int numRecievers) :
        base(position, size, rotation, flipped)
    {
        Vector2Int rotatedSize = size;

        if ((rotation % 2) == 1)
        {
            rotatedSize = new Vector2Int(size.y, size.x);
        }

        //make the body
        Rect          bodyRect = new Rect(position + new Vector2(.2f, .2f), new Vector2(rotatedSize.x - .4f, rotatedSize.y - .4f));
        ComponentBody body     = new ComponentBody(bodyRect);

        componentPieces.Add(body);

        //the size of the sensor
        Vector2 sensorSize = new Vector2(.6f, .1f);

        //incroment info
        Vector2 incromentor = new Vector2(1, 0);

        Vector2 toRecieverCorner = new Vector2(.2f, .1f);
        Vector2 recieverStartPos = Vector2.zero;

        Vector2 toSenderCorner = new Vector2(.2f, -.2f);
        Vector2 senderStartPos = new Vector2(0, rotatedSize.y);

        if (flipped)
        {
            //flipped

            if (rotation == 0)
            {
                incromentor = new Vector2(-1, 0);

                senderStartPos = new Vector2(rotatedSize.x, rotatedSize.y);
                toSenderCorner = new Vector2(-.8f, -.2f);

                recieverStartPos = new Vector2(rotatedSize.x, 0);
                toRecieverCorner = new Vector2(-.8f, .1f);
            }
            else if (rotation == 1)
            {
                incromentor = new Vector2(0, 1);
                sensorSize  = new Vector2(.1f, .6f);

                senderStartPos = new Vector2(rotatedSize.x, 0);
                toSenderCorner = new Vector2(-.2f, .2f);

                recieverStartPos = Vector2.zero;
                toRecieverCorner = new Vector2(.1f, .2f);
            }
            else if (rotation == 2)
            {
                senderStartPos = Vector2.zero;
                toSenderCorner = new Vector2(.2f, .1f);

                recieverStartPos = new Vector2(0, rotatedSize.y);
                toRecieverCorner = new Vector2(.2f, -.2f);
            }
            else if (rotation == 3)
            {
                incromentor = new Vector2(0, -1f);
                sensorSize  = new Vector2(.1f, .6f);

                senderStartPos = new Vector2(0, rotatedSize.y);
                toSenderCorner = new Vector2(.1f, -.8f);

                recieverStartPos = new Vector2(rotatedSize.x, rotatedSize.y);
                toRecieverCorner = new Vector2(-.2f, -.8f);
            }
        }
        else
        {
            //not flipped

            if (rotation == 0)
            {
                //this is the default and does nothing
            }
            else if (rotation == 1)
            {
                incromentor = new Vector2(0, -1f);
                sensorSize  = new Vector2(.1f, .6f);

                senderStartPos = new Vector2(rotatedSize.x, rotatedSize.y);
                toSenderCorner = new Vector2(-.2f, -.8f);

                recieverStartPos = new Vector2(0, rotatedSize.y);
                toRecieverCorner = new Vector2(.1f, -.8f);
            }
            else if (rotation == 2)
            {
                incromentor = new Vector2(-1, 0);

                senderStartPos = new Vector2(rotatedSize.x, 0);
                toSenderCorner = new Vector2(-.8f, .1f);

                recieverStartPos = new Vector2(rotatedSize.x, rotatedSize.y);
                toRecieverCorner = new Vector2(-.8f, -.2f);
            }
            else if (rotation == 3)
            {
                incromentor = new Vector2(0, 1);
                sensorSize  = new Vector2(.1f, .6f);

                senderStartPos = Vector2.zero;
                toSenderCorner = new Vector2(.1f, .2f);

                recieverStartPos = new Vector2(rotatedSize.x, 0);
                toRecieverCorner = new Vector2(-.2f, .2f);
            }
        }

        //make the recievers
        for (int i = 0; i < numRecievers; i++)
        {
            //Rect reciever = new Rect(position + new Vector2(.2f + i, .1f), sensorSize);
            Vector2 botLeft      = position + recieverStartPos + toRecieverCorner + (incromentor * i);
            Rect    recieverRect = new Rect(botLeft, sensorSize);

            Receiver receiver = null;

            if (this.GetType().IsSubclassOf(typeof(LinkComponent)))
            {
                int state = 1;
                state    = state << (numRecievers - 1 - i);
                receiver = new BReceiver(recieverRect, (GraphOutput)this, state);
            }
            else if (this.GetType().IsSubclassOf(typeof(LogicComponent)))
            {
                receiver = new LReceiver(recieverRect);
            }
            else
            {
                throw new System.Exception(this.GetType() + " is not supported when creating the receivers");
            }

            this.componentPieces.Add(receiver);
            this.receivers.Add(receiver);
        }

        //make the senders
        for (int i = 0; i < numSenders; i++)
        {
            Vector2 botLeft    = position + senderStartPos + toSenderCorner + (incromentor * i);
            Rect    senderRect = new Rect(botLeft, sensorSize);

            Sender sender = new Sender(senderRect);
            this.componentPieces.Add(sender);
            this.senders.Add(sender);
        }
    }