Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update tutorials to lastest engine #1

Merged
merged 4 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
/*
* Copyright 2019 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.behaviors.components;

import org.terasology.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;

/**
* If this components is attached to an NPC entity it will exhibit the flee-on-hit behavior
Expand All @@ -24,9 +11,15 @@
* When it reaches a safe distance the instigator is set to null. This component uses
* @see FleeOnHitComponent as a reference/basis.
*/
public class GroupFleeOnHitComponent implements Component {
public class GroupFleeOnHitComponent implements Component<GroupFleeOnHitComponent> {
/* Minimum distance from instigator after which the NPC will stop 'flee'ing */
public float minDistance = 10f;
/* Speed factor by which flee speed increases */
public float speedMultiplier = 1.2f;
}

@Override
public void copyFrom(GroupFleeOnHitComponent other) {
this.minDistance = other.minDistance;
this.speedMultiplier = other.speedMultiplier;
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
/*
* Copyright 2019 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.behaviors.system;

import org.terasology.behaviors.components.GroupFleeOnHitComponent;
import org.terasology.engine.Time;
import org.terasology.entitySystem.entity.EntityManager;
import org.terasology.entitySystem.entity.EntityRef;
import org.terasology.entitySystem.event.ReceiveEvent;
import org.terasology.entitySystem.systems.BaseComponentSystem;
import org.terasology.entitySystem.systems.RegisterMode;
import org.terasology.entitySystem.systems.RegisterSystem;
import org.terasology.logic.behavior.GroupTagComponent;
import org.terasology.logic.characters.CharacterMovementComponent;
import org.terasology.logic.health.event.OnDamagedEvent;
import org.terasology.registry.In;
import org.terasology.behaviors.components.FleeingComponent;
import org.terasology.behaviors.components.GroupFleeOnHitComponent;
import org.terasology.engine.core.Time;
import org.terasology.engine.entitySystem.entity.EntityManager;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.event.ReceiveEvent;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterMode;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
import org.terasology.engine.logic.behavior.GroupTagComponent;
import org.terasology.engine.logic.characters.CharacterMovementComponent;
import org.terasology.engine.registry.In;
import org.terasology.module.health.events.OnDamagedEvent;

/*
* Listens for damage events and responds according to the group behavior desired
Expand Down